-
Notifications
You must be signed in to change notification settings - Fork 14k
Stabilize ppc inline assembly #147996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Stabilize ppc inline assembly #147996
Conversation
These also accept
It would be good to document these as being controlled by |
Specifically that would require a PR like #145656 for s390x, which stabilizes the target features (and presumably also the I'd assume that with this PR merged, stabilizing the |
However, I guess LLVM/GCC could potentially generate code that relies on the VSCR fields being the same before and after inline assembly, when it is not marked as clobbered.
IIRC, these are used to store the results of SPE-specific instructions. That said, since all SPE targets are tier 3, it might be fine to ignore them and proceed with stabilization.
AFAIK, when passing values to inline assembly, the required target features themselves do not need to be stable (since #114467). Btw, s390x is a bit special in that passing values to vector registers in inline assembly requires a separate unstable feature: #133416 (This is due to vector ABI support being added after the inline assembly stabilization.) |
Yes, that would make it even more difficult to correctly mark this a clobber. Making it unusable avoids the question of whether codegen will actually preserve it.
I think the consensus is not to preserve any flags. Notably, XER is partially modeled, but we choose to ignore it. It depends on if and how LLVM/GCC would choose to expose it. |
Yes, that seems reasonable. See #148492. In general, is there any issue against relaxing restrictions post stabilization? Particularly, if we add FPSCR/VSCR preservation requirements for For FPSCR, are there active plans to support it in LLVM? |
6e3ab52 to
2f72ab8
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
At the very least we need to ensure that This matches the behavior of This should only be a documentation change, nothing needs to be done in the code.
Even if we don't expose these directly as clobbers, we still need to ensure that |
|
I've updated the reference patch require preserving all status and sticky bits of the |
This stabilizes inline assembly for PowerPC and PowerPC64.
Corresponding reference PR: rust-lang/reference#2056
From the requirements of stabilization mentioned in #93335
Done in #146949.
Done in #131341
Similarly,
preserves_flagsis also implemented by this PR. Likewise, there is a non-code change topreserve_flagsexpectations that floating point and vector status and sticky bits are preserved. The reference manual update has more details.The followings can be used as input/output:
r0,r[3-12],r[14-r28]): Any usable general-purpose registerr[3-12],r[14-r28]): General-purpose registers, but excludesr0. This is needed for instructions which definer0to be the value 0, such as register + immediate memory operations.r29on PowerPC64 targets.f[0-31]): 64 bit floating pointer registersThe following are clobber-only:
ctr,lr,xer: commonly clobbered special-purpose registers used in inline asmcr(cr[0-7],cr): the condition register fields, or the entire condition register.vreg(v[0-31]): altivec/vmx registervsreg(vs[0-63]): vector-scalar registerThe vreg and vsreg registers technically accept
#[repr(simd)]types, but require the experimentalaltivecorvsxtarget features to be enabled. That work seems to be tracked here, #42743.The following cannot be used as operands for inline asm:
r2: the TOC pointer, required for most PIC code.r13: the TLS pointerr[29]: Reserved for internal usage by LLVM on PowerPCr[30]: Reserved for internal usage by LLVM on PowerPC and PowerPC64r31: the frame pointervrsave: this is effectively an unused special-purpose register.The
preserves_flagsbehavior is updated with the following behavior (Note, this is not enforceable today due to LLVM restrictions):fpscr,spefscr, andvscrare preserved.mqis preserved (this register is only available on POWER1 and POWER2, nor is it documented in any current ABI).spe_accis preserved. This register is only available on PowerPC SPE targets.The following registers are unavailable:
mma[0-7]: These are new "registers" available on Power10, they are 512b registers which overlay 4x vsx registers. If needed, users can mark such clobbers as vsN4, vsN4+1,...,vsN*4+3.ap: This is actually a pseudo-register in gcc/llvm.cc @taiki-e
r? @Amanieu
@rustbot label +A-inline-assembly